﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace TheCup
{
    [Table("blog")]
    public class Blog
    {
        [Key]
        [Column("no")]
        public int Id { get; set; }

        [Column("Id")]
        [Obsolete]
        public Guid OldId { get; set; }
        
        [Column("DateEntry")]
        public DateTime DateEntry { get; set; }

        [DataType(DataType.Text)]
        [Display(Name = "Titel")]
        public string Title { get; set; }

        [Column("Summary")]
        [UIHint("Multiline")]
        [DataType(DataType.MultilineText)]
        [Display(Name="Indhold")]
        public string Content { get; set; }

        [Column("userno")]
        public int AuthorId { get; set; }

        [ForeignKey("AuthorId")]
        public virtual Player Author { get; set; }

        [NotMapped]
        public CommentsViewModel Comments { get; set; }

        public string DatePrintable
        {
            get
            {
                return this.DateEntry.ToLocalTime().ToString("dddd, d. MMM yyyy, kl. h:MM");
            }
        }

        public string ContentPrintable
        {
            get
            {
                return this.Content.Replace("\r\n", "<br/>");
            }
        }
    }
}